Telegram Group & Telegram Channel
Note #29 Testing.short или разделяем тестовые прогоны 📝

Недавно наткнулся на интересную тему: разделение Go тестов на быстрые или медленные те например unit и integration tests. Все собрал в короткую заметку:

A) Стандартный подход использую `testing.Short` [2]:
func TestQuick(t *testing.T) {
...
}

func TestTimeConsuming(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
}

Если выполнить:
$ go test -short
То мы пропустим тест TestTimeConsuming и выполним только TestQuick

B) Использовать build tags самый, на мой взгляд, гибкий подход:
Те создаем integration_test.go файл и добавляем билд тэги [1]:
// +build integration

func TestTimeConsuming(t *testing.T) {
// ...
}

Далее просто запускаем:
$ go test -tags=integration

С) Использовать -test.run RegExp [2]:
Можно именовать тесты с префиксом понятным всей команде:
func TestQuickUnit(t *testing.T) {
...
}

func TestIntegraion(t *testing.T) {
...
}

И далее просто:
$ go test -run Integration
$ go test -run Unit

P.S. еще как вариант можно добавить разделение с помощью переменных окружения
А как сделано в вашем проекте? Поделиться можно в личку или чат
Links:
[1] https://golang.org/pkg/go/build/
[2] https://golang.org/cmd/go/#hdr-Testing_flags
[3] https://golang.org/pkg/testing/



tg-me.com/golang_for_two/54
Create:
Last Update:

Note #29 Testing.short или разделяем тестовые прогоны 📝

Недавно наткнулся на интересную тему: разделение Go тестов на быстрые или медленные те например unit и integration tests. Все собрал в короткую заметку:

A) Стандартный подход использую `testing.Short` [2]:

func TestQuick(t *testing.T) {
...
}

func TestTimeConsuming(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
}

Если выполнить:
$ go test -short
То мы пропустим тест TestTimeConsuming и выполним только TestQuick

B) Использовать build tags самый, на мой взгляд, гибкий подход:
Те создаем integration_test.go файл и добавляем билд тэги [1]:
// +build integration

func TestTimeConsuming(t *testing.T) {
// ...
}

Далее просто запускаем:
$ go test -tags=integration

С) Использовать -test.run RegExp [2]:
Можно именовать тесты с префиксом понятным всей команде:
func TestQuickUnit(t *testing.T) {
...
}

func TestIntegraion(t *testing.T) {
...
}

И далее просто:
$ go test -run Integration
$ go test -run Unit

P.S. еще как вариант можно добавить разделение с помощью переменных окружения
А как сделано в вашем проекте? Поделиться можно в личку или чат
Links:
[1] https://golang.org/pkg/go/build/
[2] https://golang.org/cmd/go/#hdr-Testing_flags
[3] https://golang.org/pkg/testing/

BY 🇺🇦 Go for two :)


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/golang_for_two/54

View MORE
Open in Telegram


🇺🇦 Go на двоих Telegram | DID YOU KNOW?

Date: |

In many cases, the content resembled that of the marketplaces found on the dark web, a group of hidden websites that are popular among hackers and accessed using specific anonymising software.“We have recently been witnessing a 100 per cent-plus rise in Telegram usage by cybercriminals,” said Tal Samra, cyber threat analyst at Cyberint.The rise in nefarious activity comes as users flocked to the encrypted chat app earlier this year after changes to the privacy policy of Facebook-owned rival WhatsApp prompted many to seek out alternatives.

A project of our size needs at least a few hundred million dollars per year to keep going,” Mr. Durov wrote in his public channel on Telegram late last year. “While doing that, we will remain independent and stay true to our values, redefining how a tech company should operate.

🇺🇦 Go на двоих from in


Telegram 🇺🇦 Go for two :)
FROM USA